<?php
namespace Orm\PlayType;

use Base\Exception\RmException;
class PlayTypeClass extends \Base\BaseOrmObject{
    protected   $id,
				$name = '', // 场次类别
				$is_del = 0,
				$insert_time = '',
				$update_time = '';

    function __init($data)
    {
        parent::__init($data);
        $this->dformat($data);
    }

    private function dformat()
    {
    }

    public function loadById($id = 0)
    {
        $model = new \Orm\PlayType\PlayTypeModel();
        $data = $model->loadById($id);
        self::__init($data);
    }

    public function insert()
    {
        $this->checkNecessaryParam();
        $data = array(
            'name' => $this->name,
        );

        $model = new \Orm\PlayType\PlayTypeModel();
        $model->insert($data);
        $this->id = $model->getLastId();
    }

    public function update()
    {
        $this->checkNecessaryParam();
        $data = array(
            'name' => $this->name,
        );

        $model = new \Orm\PlayType\PlayTypeModel();
        $model->update($data, "`id` = {$this->id}");
    }

    public function delete($id)
    {
        $data = array('is_del'=>1);
        $model = new \Orm\PlayType\PlayTypeModel();
        $model->update($data, "`id` = {$id}");
    }

    private function checkNecessaryParam()
    {
    }
}